[duvida/erros]allegro+gcc [RESOLVIDO]

1. [duvida/erros]allegro+gcc [RESOLVIDO]

Alex Fernando Ferreira
staltux

(usa Slackware)

Enviado em 28/12/2007 - 02:30h

instalei o allegro pelo
sudo apt-get install liballegro4.2-dev
mas na hora de compila esse esqueleto da varios erros...

#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
int inicia(void);
void principal(void);
void finaliza(void);
int main (void)
{
if (!inicia())
{
finaliza();
exit(-1);
}
principal();

finaliza();
exit(0);
}
int inicia (void)
{

allegro_init();

install_keyboard();
install_mouse();
install_timer();

set_color_depth(8);
set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
return(TRUE);
}

void principal (void)
{
printf("iniciado com sucesso!");
}

void finaliza (void)
{
allegro_exit();
}
abaixo os erros
eu to achando que é muito erro pra um programa pequeno desses...como tem muita coisa vo posta só algums...
-------------------------------------------
site.c:42:8: warning: no newline at end of file
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_open_display':
(.text+0x67): undefined reference to `XOpenDisplay'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_open_display':
(.text+0x7b): undefined reference to `XDefaultScreen'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_hide_x_mouse':
(.text+0xc4): undefined reference to `XUndefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_hide_x_mouse':
(.text+0xe2): undefined reference to `XcursorImageDestroy'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_hide_x_mouse':
(.text+0x101): undefined reference to `XCreatePixmap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_hide_x_mouse':
(.text+0x136): undefined reference to `XCreateGC'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_hide_x_mouse':
(.text+0x14b): undefined reference to `XDrawPoint'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o):
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1964':
(.text+0xbb5b): undefined reference to `XSync'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1964':
(.text+0xbe35): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1964':
(.text+0xbed5): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1964':
(.text+0xbf75): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc120): undefined reference to `XF86VidModeGetAllModeLines'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc18a): undefined reference to `XF86VidModeSwitchToMode'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc1a4): undefined reference to `XF86VidModeLockModeSwitch'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc1be): undefined reference to `XMoveWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc1d1): undefined reference to `XF86VidModeSetViewPort'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc29b): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc2a8): undefined reference to `XSync'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc2b1): undefined reference to `XDefaultRootWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc2c4): undefined reference to `XGrabKeyboard'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc2f5): undefined reference to `XGrabPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc5ca): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc5eb): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc60c): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L1971':
(.text+0xc627): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `free_modelines':
(.text+0xc722): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `free_modelines':
(.text+0xc74e): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `free_modelines':
(.text+0xc79d): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `free_modelines':
(.text+0xc7b8): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `free_modelines':
(.text+0xc7d3): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o):(.text+0xc7ee): more undefined references to `XFree' follow
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xca62): undefined reference to `XUnmapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xca7c): undefined reference to `XUngrabPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xcaa8): undefined reference to `XUngrabKeyboard'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xcada): undefined reference to `XChangeWindowAttributes'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xcafd): undefined reference to `XShmDetach'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xcb3b): undefined reference to `XF86VidModeLockModeSwitch'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xcb53): undefined reference to `XF86VidModeSwitchToMode'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xccea): undefined reference to `XcursorImageDestroy'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcd0d): undefined reference to `XFreeGC'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcd5a): undefined reference to `XUndefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcd68): undefined reference to `XFreeCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcd87): undefined reference to `XUnmapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcd95): undefined reference to `XDestroyWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcdac): undefined reference to `XUninstallColormap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xcdba): undefined reference to `XFreeColormap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_close_display':
(.text+0xce28): undefined reference to `XCloseDisplay'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_fetch_mode_list':
(.text+0xceed): undefined reference to `XF86VidModeQueryExtension'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_fetch_mode_list':
(.text+0xcf07): undefined reference to `XF86VidModeQueryVersion'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_fetch_mode_list':
(.text+0xcf24): undefined reference to `XF86VidModeGetAllModeLines'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_set_mouse_sprite':
(.text+0xd0f7): undefined reference to `XcursorImageDestroy'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_set_mouse_sprite':
(.text+0xd13e): undefined reference to `XcursorImageCreate'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(digmid.o): In function `digmid_init':
(.text+0x68b): undefined reference to `pow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_load_modules':
(.text+0x23d): undefined reference to `dlopen'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_load_modules':
(.text+0x259): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x39e): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x3b2): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x3d7): undefined reference to `dlclose'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_thread_func':
(.text+0x28): undefined reference to `pthread_sigmask'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_init':
(.text+0x20c): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_exit':
(.text+0x266): undefined reference to `pthread_join'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_threadfunc':
(.text+0x29): undefined reference to `pthread_sigmask'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_init':
(.text+0x300): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_exit':
(.text+0x370): undefined reference to `pthread_join'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `find_unknown_key_assignment':
(.text+0xef): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `find_unknown_key_assignment':
(.text+0x13d): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o):
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_vline':
(.text+0x73a): undefined reference to `XDrawLine'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_rectfill':
(.text+0x9a2): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_rectfill':
(.text+0x9cd): undefined reference to `XFillRectangle'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_clear_to_color':
(.text+0xbb9): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_clear_to_color':
(.text+0xbe6): undefined reference to `XFillRectangle'
collect2: ld returned 1 exit status
------------------------------------------------
estou compilando usado o codigo
gcc -o site site.c -lalleg


  


2. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Marcelo Utikawa da Fonseca
utikawa

(usa Ubuntu)

Enviado em 29/12/2007 - 00:17h

Parecem erros de versão da biblioteca. Mas a linha que me chamou a atenção é a que diz que a função main não foi definida... Mas a função está no seu código!
Faça o seguinte: comente o conteúdo das funções inicia e finaliza. O programa compila ou ainda dá algum erro?


3. ainda nao

Alex Fernando Ferreira
staltux

(usa Slackware)

Enviado em 29/12/2007 - 16:01h

nao mas diminui os erros...só da esses:
teste.c:46:2: warning: no newline at end of file
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
o que é esse no newline at end of file...algums do programas que eu baixo da net tambem da esse erro...


4. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Marcelo Utikawa da Fonseca
utikawa

(usa Ubuntu)

Enviado em 29/12/2007 - 17:48h

no newline at end of file: traduzindo significa que não há nova linha no fim do arquivo, ou seja, o arquivo não termina com quebra de linha. Eu não tenho certeza o motivo desse aviso mas é que o gcc não gosta que o seu arquivo não termine com uma linha vazia... :-)

Quanto ao problema de compilação em si: é estranho e eu pedi para comentar todo o restante pois realmente eu havia visto este erro que sobrou e queria ver se continuaria acontecendo.
Faça o seguinte: copie o conteúdo abaixo para um arquivo e compile:

int main()
{
return 0;
}


Para compilar utilize:

gcc -o main main.c

Se der o erro novamente é alguma coisa com o seu compilador.


5. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Tiago Matos Santos
tiagomatos

(usa Debian)

Enviado em 26/01/2008 - 18:38h

eu tive esse problema ...
tem que adicionar referência para mais bibliotecas,

adicione isso na linha de comando
-lX11 -lXpm -lpthread -lXcursor -lXxf86vm -lm

acho que é só isso mas talvez precise de mais alguma dependendo do que vc tiver usando


6. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Daniel
code0

(usa Slackware)

Enviado em 05/03/2008 - 13:35h

Veja a documentacao do Allegro que voce entendera seu erro.
Faltou a macro END_OF_MAIN apos o final da funcao main:

#include <allegro.h>

int main(void)
{
bla bla bla
}
END_OF_MAIN();

Para compilar tente assim:
gcc -o programa arquivo.c `allegro-config --libs`




7. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Luciano Gomes
lucianopqd

(usa Ubuntu)

Enviado em 05/03/2008 - 13:58h

que porra de programa é esse..rss


8. Re: [duvida/erros]allegro+gcc [RESOLVIDO]

Alex Fernando Ferreira
staltux

(usa Slackware)

Enviado em 03/07/2009 - 22:01h

vlw a todos pelas respostas e disculpe nao ter respondido antes...
muito estranho usar macro pra finalizar main...coisa loca...vlw






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts